package common;

import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Enumeration;

public class NetworkParameters {

	public static final int backoffPeriod = 5;
	public static final int numPings = 1;

	public static URI getLocalURI(String networkInterface)
			throws SocketException {
		URI localURI = null;
		Enumeration<InetAddress> inetAddresses = NetworkInterface.getByName(
				networkInterface).getInetAddresses();
		inetAddresses.nextElement();
		boolean ok;
		do {
			ok = true;
			try {
				localURI = new URI(inetAddresses.nextElement().getHostAddress());
			} catch (URISyntaxException e) {
				ok = false;
			}
		} while (ok == false);
		return localURI;
	}

}
